package com.eaoa.uc.account.form;

import org.apache.commons.lang.StringUtils;

import com.eaoa.base.EABaseForm;
import com.eaoa.vo.pub.PubAccount;
import com.eaoa.vo.pub.PubCustomer;
import com.stony.core.util.CoreUtils;

public class AccountForm extends EABaseForm {

	// primary key
	private String employeeno;

	// fields
	private String username;
	private String password;
	private String password2;
	private String name;
	private String email;
	private String telephone;
	private String mobilephone;
	private String customerno;
	private String customername;
	private String islock;
	private String employeetype;
	private String accounttype;
	private String faxphone;
	private String ispersonal;
	

	public PubAccount getVo() {

		PubAccount vo = new PubAccount();
		vo.setAccountno(CoreUtils.parseLong(this.getEmployeeno()));
		if (StringUtils.isNotBlank(this.getCustomerno()))
			vo.setCompany(new PubCustomer(CoreUtils.parseLong(this.getCustomerno())));
		vo.setUsername(username);
		vo.setPassword(password);
		vo.setName(name);
		vo.setEmail(this.getEmail());
		vo.setTelephone(telephone);
		vo.setMobilephone(mobilephone);
		vo.setIslock(islock);
		vo.setFaxphone(faxphone);
		vo.setEmployeeType(CoreUtils.parseLong(this.getEmployeetype()));
		vo.setAccounttype(this.getAccounttype());
		return vo;
	}

	public void setVo(PubAccount vo) {

		this.setEmployeeno(CoreUtils.formatString(vo.getAccountno()));

		this.setUsername(vo.getUsername());
		this.setName(vo.getName());
		this.setEmail(vo.getEmail());
		this.setTelephone(vo.getTelephone());
		this.setMobilephone(vo.getMobilephone());
		this.setIslock(vo.getIslock());
		this.setEmployeetype(CoreUtils.formatString(vo.getEmployeeType()));
		this.setAccounttype(vo.getAccounttype());
		if(vo.getCompany()!=null){
			this.setCustomerno(CoreUtils.formatString(vo.getCompany().getCustomerno()));
			this.setCustomername(vo.getCompany().getCustomercode() +"-"+ vo.getCompany().getNameshort());
		}
		this.setFaxphone(vo.getFaxphone());
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getCustomerno() {
		return customerno;
	}

	public void setCustomerno(String customerno) {
		this.customerno = customerno;
	}

	public String getEmployeeno() {
		return employeeno;
	}

	public void setEmployeeno(String employeeno) {
		this.employeeno = employeeno;
	}
	
	public String getIslock() {
		return islock;
	}

	public void setIslock(String islock) {
		this.islock = islock;
	}

	public String getMobilephone() {
		return mobilephone;
	}

	public void setMobilephone(String mobilephone) {
		this.mobilephone = mobilephone;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getFaxphone() {
		return faxphone;
	}

	public void setFaxphone(String faxphone) {
		this.faxphone = faxphone;
	}

	public String getEmployeetype() {
		return employeetype;
	}

	public void setEmployeetype(String employeetype) {
		this.employeetype = employeetype;
	}

	public String getCustomername() {
		return customername;
	}

	public void setCustomername(String customername) {
		this.customername = customername;
	}

	public String getIspersonal() {
		return ispersonal;
	}

	public void setIspersonal(String ispersonal) {
		this.ispersonal = ispersonal;
	}

	public String getAccounttype() {
		return accounttype;
	}

	public void setAccounttype(String accounttype) {
		this.accounttype = accounttype;
	}

	public String getPassword2() {
		return password2;
	}

	public void setPassword2(String password2) {
		this.password2 = password2;
	}

}